cmake_minimum_required(VERSION 3.16)

project(kylin-os-manager LANGUAGES CXX)

set(TOP_DIR ${CMAKE_CURRENT_LIST_DIR}/../)
set(SRC_DIR ${CMAKE_CURRENT_LIST_DIR})
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

add_executable(${PROJECT_NAME})

target_compile_options(${PROJECT_NAME} PRIVATE -Wall -g)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)

find_package(PkgConfig REQUIRED)

find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Widgets)

target_include_directories(${PROJECT_NAME} PRIVATE ${TOP_DIR}/3rdparty/kyplugin)
target_link_libraries(${PROJECT_NAME} PRIVATE kyplugin)

pkg_check_modules(KYSDKQTWIDGETS_PKG kysdk-qtwidgets)
target_include_directories(${PROJECT_NAME} PRIVATE ${KYSDKQTWIDGETS_PKG_INCLUDE_DIRS})
target_link_directories(${PROJECT_NAME} PRIVATE ${KYSDKQTWIDGETS_PKG_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${KYSDKQTWIDGETS_PKG_LIBRARIES})

pkg_check_modules(KYSDKKABASE_PKG kysdk-kabase)
target_include_directories(${PROJECT_NAME} PRIVATE ${KYSDKKABASE_PKG_INCLUDE_DIRS})
target_link_directories(${PROJECT_NAME} PRIVATE ${KYSDKKABASE_PKG_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${KYSDKKABASE_PKG_LIBRARIES})

pkg_check_modules(KYSDK_UKENV kysdk-ukenv)
target_include_directories(${PROJECT_NAME} PRIVATE ${KYSDK_UKENV_INCLUDE_DIRS})
target_link_directories(${PROJECT_NAME} PRIVATE ${KYSDK_UKENV_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${KYSDK_UKENV_LIBRARIES})

set(SRCS
	"${SRC_DIR}/main.cpp"
	"${SRC_DIR}/mainwindow.cpp"
	"${SRC_DIR}/common.h"
	"${SRC_DIR}/mainwindow.h"
	"${SRC_DIR}/utils.h"
	"${SRC_DIR}/utils.cpp"
	"res.qrc"
	"${TOP_DIR}/interface/kymanager_plugin.cpp")

set(TRANSLATIONS
	"${TOP_DIR}/translations/kylin-os-manager_zh_CN.ts"
	"${TOP_DIR}/translations/kylin-os-manager_bo_CN.ts"
	"${TOP_DIR}/translations/kylin-os-manager_ug.ts"
	"${TOP_DIR}/translations/kylin-os-manager_kk.ts"
	"${TOP_DIR}/translations/kylin-os-manager_ky.ts")
set_source_files_properties(${TRANSLATIONS} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")
qt5_add_translation(QM_FILES ${TRANSLATIONS})

target_include_directories(${PROJECT_NAME} PRIVATE ${TOP_DIR}/interface)
target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_DIR})
target_sources(${PROJECT_NAME} PRIVATE ${SRCS} ${QM_FILES})

install(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin)
install(FILES ${QM_FILES} DESTINATION  /usr/share/kylin-os-manager/translations/)
install(DIRECTORY ${TOP_DIR}/data/user-manual/ DESTINATION /usr/share/kylin-user-guide/data/guide/kylin-os-manager/)
